package com.gaobug.platform.controller;

import com.gaobug.base.cache.constant.LikeRedisKey;
import com.gaobug.base.cache.constant.RedisCharSequence;
import com.gaobug.base.response.ResponseWrapped;
import com.gaobug.platform.dto.VoteDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/blog/check")
@RestController
public class BlogCheckController {
//    @Resource
//    private VoteBox voteBox;

    @PostMapping("/article/like")
    public ResponseWrapped<Object> checkArticleLike(@RequestBody VoteDTO voteDTO) {
//        Integer count = voteBox.vote(LikeRedisKey.LIKE_INFO + ":" + voteDTO.getTargetType() + "::" + voteDTO.getTargetId(),
//                voteDTO.getTargetType() + "::" + voteDTO.getTargetId(),
//                LikeRedisKey.LIKE_COUNT + ":" + voteDTO.getTargetType() + ":" + voteDTO.getTargetId(),
//                voteDTO.getLikeFlag(),
//                10 * 60 * 1000L);
//        VoteVO voteVO = new VoteVO(voteDTO.getTargetId(), voteDTO.getTargetType(), count);
        return ResponseWrapped.success();
    }

    public String getVoteKey(VoteDTO voteDTO) {
        StringBuilder sb = new StringBuilder();
        sb.append(LikeRedisKey.LIKE_INFO);
        sb.append(RedisCharSequence.colon);
        sb.append(voteDTO.getTargetId());
        return sb.toString();
    }

    @PostMapping("/comment/like")
    public ResponseWrapped<Object> checkCommentLike(@RequestBody VoteDTO voteDTO) {
        return ResponseWrapped.success();
    }
}
